package com.easytopit.demo.service.impl;

import java.sql.Timestamp;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.easytopit.demo.dao.MovieMapper;
import com.easytopit.demo.dao.OrderMapper;
import com.easytopit.demo.domain.Order;
import com.easytopit.demo.domain.enumDomain.OrderStatus;
import com.easytopit.demo.domain.enumDomain.PayStatus;
import com.easytopit.demo.domain.enumDomain.Version;
import com.easytopit.demo.service.OrderService;

@Service
public class OrderServiceImpl implements OrderService{
	
	@Autowired
	private OrderMapper orderMapper;
	@Autowired
	private MovieMapper movieMapper ;
	
	@Override
	public Double userBalance(String name) {
		return orderMapper.userBalance(name);
	}

	@Override
	public void addMoney(String name, double money) {
		orderMapper.addMoney(name, money);
	}

	@Override
	public void addOrder(String id,String userName, String cinema, String hall, String movieName, String movieTime,String version,String language,
			String info,Integer quantity, Double price, Double money, String createTime, String endTime,String orderStatus, String payStatus) {
		Order order = new Order();
		order.setId(id);
		order.setUserName(userName);
		order.setCinema(cinema);
		order.setHall(hall);
		order.setMovieName(movieName);
		order.setMovieTime(movieTime);
		order.setVersion(version);
		order.setInfo(info);
		order.setQuantity(quantity);
		order.setPrice(price);
		order.setMoney(money);
		order.setCreateTime(createTime);
		order.setEndTime(endTime);
		order.setOrderStatus(orderStatus);
		order.setPayStatus(payStatus);
		orderMapper.addOrder(order);
	}

	@Override
	public Order queryOrderById(String id) {
		return orderMapper.queryOrderById(id);
	}
	
	@Override
	public void reduceBalance(String name, Double money) {
		orderMapper.reduceBalance(name,money);
	}
	
	@Override
	public void addBalance(String name, Double money) {
		orderMapper.addBalance(name, money);
	}

	@Override
	public List<Order> queryOrderByName(String name) {
		return orderMapper.queryOrderByName(name);
	}

	@Override
	public boolean payOrder(String num, String time) {
		return orderMapper.payOrder(num, time);
	}

	@Override
	public boolean refundOrder(String num, String time) {
		return orderMapper.refundOrder(num, time);
	}

	@Override
	public List<Order> searchOrder(String name,String num, String payStatus, String createTime, String endTime, String cinema) {
		return orderMapper.searchOrder(name, num, payStatus, createTime, endTime, cinema);
	}
	

	
}